parallel-debian: Rework scripts to not use loopback mounts
authorColin Walters <walters@verbum.org>
Wed, 26 Oct 2011 22:42:55 +0000 (18:42 -0400)
committerColin Walters <walters@verbum.org>
Wed, 26 Oct 2011 22:42:55 +0000 (18:42 -0400)
It's not necessary and adds a lot of overhead for the build. Instead,
just dynamically make an ext4 image of the fs when booting in QEMU.

parallel-debian/Makefile
parallel-debian/gnomeos-install.sh
parallel-debian/gnomeos-make-image.sh
parallel-debian/gnomeos-run.sh

index e72410e05e16d97e47fa94de0dca615b6d809c0a..97ec6c002f7228a7cbcb13aaedf265fc09ed1651 100644 (file)
@@ -1,3 +1,8 @@
 
+all: ostree_switch_root chroot_break
+
 ostree_switch_root: ostree_switch_root.c Makefile
        gcc -Wall -o $@ $<
+
+chroot_break: chroot_break.c Makefile
+       gcc -Wall -o $@ $<
index 650d2508431ed32f4c16002647ca8072f1000872..24752dfed52ddf8d58f3b7b0fd20bd3933d3e43e 100755 (executable)
@@ -35,11 +35,7 @@ if test -d /ostree; then
     exit 1
 fi
 
-mkdir -p fs
-umount fs || true
-mount -o loop gnomeos-filesystem.img fs
-cp -a fs/ostree /
-umount fs
+cp -a gnomeos-fs/ostree /
 initrd=`readlink gnomeos-initrd.img`
 cp ${initrd} /boot
 grubby --title "GNOME OS" --add-kernel=$kernel --copy-default --initrd=/boot/${initrd}
index 0d706546b10ede2391429de5f7870842f348ed5a..bcea8bd7c322ddd917cfc7eff92022cf39ff4dd4 100755 (executable)
@@ -69,33 +69,17 @@ if ! test -d ${OBJ} ; then
     mv ${OBJ}.tmp ${OBJ}
 fi
 
-OBJ=$DEBTARGET.img
-if ! test -f ${OBJ}; then
-    umount fs || true
-    mkdir -p fs
-    qemu-img create ${OBJ}.tmp 2G
-    mkfs.ext4 -q -F ${OBJ}.tmp
-    mount -o loop ${OBJ}.tmp fs
+OBJ=$DEBTARGET-fs
+if ! test -d ${OBJ}; then
+    rm -rf ${OBJ}.tmp
+    mkdir ${OBJ}.tmp
 
     for d in debootstrap-$DEBTARGET/var/cache/apt/archives/*.deb; do
         rm -rf work; mkdir work
-        (cd work && ar x ../$d && tar -x -z -C ../fs -f data.tar.gz)
+        (cd work && ar x ../$d && tar -x -z -C ../${OBJ}.tmp -f data.tar.gz)
     done
 
-    umount fs
-    mv ${OBJ}.tmp ${OBJ}
-fi
-
-# TODO download source for above
-# TODO download build dependencies for above
-
-OBJ=gnomeos-filesystem.img
-if ! test -f ${OBJ}; then
-    cp -a --sparse=always $DEBTARGET.img ${OBJ}.tmp
-    mkdir -p fs
-    umount fs || true
-    mount -o loop ${OBJ}.tmp fs
-    (cd fs;
+    (cd ${OBJ}.tmp;
         mkdir ostree
         mkdir ostree/repo
         mkdir ostree/gnomeos-origin
@@ -114,21 +98,44 @@ if ! test -f ${OBJ}; then
             fi
         done
 
+        $OSTREE init --repo=ostree/repo
+        (cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -s 'Initial import' --repo=../repo --from-stdin)
+    )
+    if test -d ${OBJ}; then
+        mv ${OBJ} ${OBJ}.old
+    fi
+    mv ${OBJ}.tmp ${OBJ}
+    rm -rf ${OBJ}.old
+fi
+
+# TODO download source for above
+# TODO download build dependencies for above
+
+OBJ=gnomeos-fs
+if ! test -d ${OBJ}; then
+    rm -rf ${OBJ}.tmp
+    cp -al $DEBTARGET-fs ${OBJ}.tmp
+    (cd ${OBJ}.tmp;
+
         cp ${SRCDIR}/debian-setup.sh ostree/gnomeos-origin/
         chroot ostree/gnomeos-origin ./debian-setup.sh
         rm ostree/gnomeos-origin/debian-setup.sh
+        (cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -s 'Run debian-setup.sh' --repo=../repo --from-stdin)
+
+        cp -p ${SRCDIR}/chroot_break ostree/gnomeos-origin/sbin/chroot_break
+        (cd ostree/gnomeos-origin; $OSTREE commit -s 'Add chroot_break' --repo=../repo --add=sbin/chroot_break)
 
-        $OSTREE init --repo=ostree/repo
-        (cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -s 'Initial import' --repo=../repo --from-stdin)
-        rm -rf ostree/gnomeos-origin
         (cd ostree;
             rev=`cat repo/HEAD`
             $OSTREE checkout --repo=repo HEAD gnomeos-${rev}
             $OSTREE run-triggers --repo=repo current
             ln -s gnomeos-${rev} current)
     )
-    umount fs
+    if test -d ${OBJ}; then
+        mv ${OBJ} ${OBJ}.old
+    fi
     mv ${OBJ}.tmp ${OBJ}
+    rm -rf ${OBJ}.old
 fi
 
 cp ${SRCDIR}/ostree_switch_root ${WORKDIR}
index fe2f820445fe631d5cdb340745f070db4c25fa96..9691a85da405b81d93e07d0eb421097689098571 100755 (executable)
@@ -24,11 +24,22 @@ set -x
 SRCDIR=`dirname $0`
 WORKDIR=`pwd`
 
-OBJ=gnomeos-initrd.img
-if ! test -f ${OBJ}; then
-    echo "Error: couldn't find '$OBJ'. Run gnomeos-make-image.sh"
+if ! test -d gnomeos-fs; then
+    echo "Error: couldn't find gnomeos-fs. Run gnomeos-make-image.sh"
     exit 1
 fi
 
-umount fs || true
-exec qemu-kvm -kernel `grubby --default-kernel` -initrd gnomeos-initrd.img -hda gnomeos-filesystem.img -append "root=/dev/sda ostree=current"
+OBJ=gnomeos-fs.img
+if (! test -f ${OBJ}) || test gnomeos-fs -nt ${OBJ}; then
+    rm -f ${OBJ}.tmp
+    qemu-img create ${OBJ}.tmp 2G
+    mkfs.ext4 -q -F ${OBJ}.tmp
+    mkdir -p fs
+    umount fs || true
+    mount -o loop ${OBJ}.tmp fs
+    cp -a gnomeos-fs/* fs
+    umount fs
+    mv ${OBJ}.tmp ${OBJ}
+fi
+
+exec qemu-kvm -kernel `grubby --default-kernel` -initrd gnomeos-initrd.img -hda gnomeos-fs.img -append "root=/dev/sda ostree=current"